<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateShopShareTable extends Migrator
{
    /**
     * Migrate Up.
     */
    public function up()
    {
        $table = $this->table('shop_share', ['comment' => '用户分享记录', 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci']);
        $table->addColumn('spm', 'string', ['limit' => 255, 'null' => true, 'default' => null, 'comment' => '原始spm'])
            ->addColumn('user_id', 'integer', ['limit'  =>  11, 'default' => 0, 'comment' => '用户'])
            ->addColumn('share_id', 'integer', ['limit'  =>  11, 'default' => 0, 'comment' => '分享人'])
            ->addColumn('page', 'string', ['limit' => 255, 'null' => true, 'default' => null, 'comment' => '分享页面'])
            ->addColumn('query', 'string', ['limit' => 255, 'null' => true, 'default' => null, 'comment' => '分享页面参数'])
            ->addColumn('platform', 'string', ['limit' => 50, 'null' => true, 'default' => null, 'comment' => '分享平台'])
            ->addColumn('from', 'string', ['limit' => 20, 'null' => true, 'default' => null, 'comment' => '分享方式'])
            ->addColumn('ext', 'text', ['null' => true, 'default' => null, 'comment' => '附加信息'])
            ->addColumn('create_time', 'integer', ['limit'  =>  10, 'null' => true, 'default' => null, 'comment' => '创建时间'])
            ->addIndex('user_id')
            ->addIndex('share_id')
            ->create();
    }


    /**
     * Migrate Down.
     */
    public function down()
    {
        $table = $this->table('shop_share');
        $table->drop();
    }
}
